//
//  RootViewController.m
//  珑门众筹
//
//  Created by longmen2 on 16/3/14.
//  Copyright © 2016年 gengsensen. All rights reserved.
//

#import "RootViewController.h"
#import "ChangeViewController.h"
#import "ListViewController.h"
#import "PersonViewController.h"
#import "RDVTabBarItem.h"
@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createControllers];
    self.tabBar.backgroundColor = [UIColor blueColor];
    
}

-(void)createControllers
{
    
    //精选
    ChangeViewController * protuctVC = [[ChangeViewController alloc]init];
    UINavigationController *nc2 = [[UINavigationController alloc]initWithRootViewController:protuctVC];
    
    //列表
    ListViewController * accountVC = [[ListViewController alloc]init];
    UINavigationController *nc3 = [[UINavigationController alloc]initWithRootViewController:accountVC];
    
    //个人中心
    PersonViewController * mineVC = [[PersonViewController alloc]init];
    UINavigationController *nc4 = [[UINavigationController alloc]initWithRootViewController:mineVC];
    
    self.viewControllers = @[nc2,nc3,nc4];
    //设置tabbar上的信息
    [self customTabbar];
}
-(void)customTabbar
{
    
    //设置tabbar上的图片
    NSArray * tabArr = @[@"",@"",@""];
    //设置tabbar上的文字
    NSArray * titleArr = @[@"精选",@"列表",@"个人中心"];
    NSDictionary *textAttributes_normal = nil;
    NSDictionary *textAttributes_selected = nil;
    if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_0) {
        textAttributes_normal = @{
                                  NSFontAttributeName:[UIFont systemFontOfSize:10],
                                  NSForegroundColorAttributeName:[UIColor colorWithRed:65/255.0 green:65/255.0 blue:65/255.0 alpha:1]};
        textAttributes_selected = @{
                                    NSFontAttributeName:[UIFont systemFontOfSize:10],
                                    NSForegroundColorAttributeName:[UIColor colorWithRed:255/255.0 green:128/255.0 blue:107/255.0 alpha:1]};
    }
    NSInteger index = 0;
    for (RDVTabBarItem * item in self.tabBar.items) {
        item.backgroundColor = [UIColor whiteColor];
        item.unselectedTitleAttributes = textAttributes_normal;
        item.selectedTitleAttributes = textAttributes_selected;
        UIImage *normalImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_nor",[tabArr objectAtIndex:index]]];
        UIImage *selectImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_over",[tabArr objectAtIndex:index]]];
        [item setFinishedSelectedImage:selectImage withFinishedUnselectedImage:normalImage];
        item.title = titleArr[index];
        index++;
        
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
